package cn.e4j.modular.api.service;

import cn.e4j.core.dto.impl.Dto;
import cn.e4j.modular.api.mapper.XcqdMapper;
import cn.e4j.modular.crm.entity.*;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 *功能描述
 * @author caijy
 * @description 现场回报
 * @datetime 2019-11-11 0011 9:32
 * @return
 */

@Service
public class XcqdService{

    @Autowired
    XcqdMapper xcqdMapper;


    /**
     * 现场回报保存
     *
     * @param
     * @return
     */
    @Transactional
    public void saveData(MmrgT mmrgT, List<MmrhT> MmrhTs, List<MmriT> MmriTs, MmrdT mmrdT, List<MmrqT> mmrqTS) {
        mmrgT.insert();

        for(MmrhT mmrhT : MmrhTs){
            mmrhT.insert();
        }

        for(MmriT mmriT : MmriTs){
            mmriT.insert();
        }

        for(MmrqT mmrqT : mmrqTS){
            mmrqT.insert();
        }

        //修改状态
        // WHERE  mmrdent = #{mmrdent} AND mmrddocno = #{mmrddocno} AND mmrdseq = #{mmrdseq}
        UpdateWrapper<MmrdT> wrapper1 = new UpdateWrapper<>();
        wrapper1.eq("MMRDENT",mmrdT.getMMRDENT());
        wrapper1.eq("MMRDDOCNO",mmrdT.getMMRDDOCNO());
        wrapper1.eq("MMRDSEQ",mmrdT.getMMRDSEQ());

        mmrdT.update(wrapper1);

    }

}
